package com.studysystem.controller;

import com.studysystem.dto.RegisterRequest;
import com.studysystem.entity.User;
import com.studysystem.service.UserService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/auth")
public class AuthController {
    private final UserService userService;

    public AuthController(UserService userService) {
        this.userService = userService;
    }

    @PostMapping("/register")
    public ResponseEntity<?> register(@RequestBody RegisterRequest request) {
        User user = new User();
        user.setUsername(request.getUsername());
        user.setPassword(request.getPassword()); // 明文保存
        user.setEmail(request.getEmail());
        user.setFullName(request.getFullName());
        userService.registerUser(user);
        return ResponseEntity.ok("注册成功");
    }
} 